package com.lyluly.coursemgmt.servicemodule.iService.serviceImpl;

import com.lyluly.coursemgmt.servicemodule.iDao.QuAnsMapper;
import com.lyluly.coursemgmt.servicemodule.iService.IQuAnsService;
import com.lyluly.coursemgmt.servicemodule.model.QuAns;
import com.lyluly.coursemgmt.servicemodule.model.QuAnsExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class QuAnsServiceImpl implements IQuAnsService {
    @Autowired
    private QuAnsMapper quAnsMapper;

    public void addQuAns(QuAns quAns) {
        quAns.setCreatetime(new Date());
        quAnsMapper.insert(quAns);
    }

    public void modifyQuAns(QuAns quAns) {
        quAnsMapper.updateByPrimaryKeySelective(quAns);
    }

    public void removeQuAns(int quAnsId) {
        quAnsMapper.deleteByPrimaryKey(quAnsId);
    }

    public QuAns findQuAnsById(int quAnsId) {
        return quAnsMapper.selectByPrimaryKey(quAnsId);
    }

    public List<QuAns> findQuAnsList() {
        return quAnsMapper.selectByExample(null);
    }

    public List<QuAns> findQuAnsListBySId(String sId) {
        QuAnsExample quAnsExample = new QuAnsExample();
        quAnsExample.or().andSIdEqualTo(sId);
        return quAnsMapper.selectByExample(quAnsExample);
    }

    public List<QuAns> findQuAnsListByTId(String tId) {
        QuAnsExample quAnsExample = new QuAnsExample();
        quAnsExample.or().andTIdEqualTo(tId);
        return quAnsMapper.selectByExample(quAnsExample);
    }
}
